package com.szml.common.app.constant;

public enum OperationEnum {
    ADD(1, "新增"),
    INITIATE_APPROVAL(2, "发起审批"),
    APPROVE_PASS(3, "审批通过"),
    APPROVE_REJECT(4, "审批驳回"),
    GO_LIVE(5, "上线"),
    TAKE_OFFLINE(6, "下线");

    private final int code;
    private final String attribute;

    OperationEnum(int code, String attribute) {
        this.code = code;
        this.attribute = attribute;
    }

    public int getCode() {
        return code;
    }

    public String getAttribute() {
        return attribute;
    }

    public static OperationEnum getByCode(int code) {
        for (OperationEnum operation : values()) {
            if (operation.getCode() == code) {
                return operation;
            }
        }
        throw new IllegalArgumentException("Invalid operation code: " + code);
    }
}